package com.song.test;

import java.math.BigInteger;
import java.util.Random;

/**
 * @Author Klys
 * @Date 2023/6/14 17:17
 * @Description
 * @Version 1.0
 */
public class LongUtils {

    public static void main(String[] args) {
        LongUtils longDemo = new LongUtils();
        Long l = longDemo.randomLong12();
        Long absL = longDemo.absLong(l);
        String s = longDemo.long12toString(absL);
        System.out.println(s);
    }

    /**
     * @Author Klys
     * @Description 随机生成12位的Long
     */
    public Long randomLong12() {
        Random random = new Random();
        return random.nextLong() % 1000000000000L;
    }

    /**
     * @Author Klys
     * @Description 12位的long转换成String
     */
    public String long12toString(Long l) {
        String replace = String.format("%12d", l).replace(" ", "0");
        return replace;
    }

    /**
     * @Author Klys
     * @Description Long类型取绝对值
     */
    public Long absLong(Long l) {
        long absLong = Math.abs(l);
        return absLong;
    }
}
